﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Boom : MonoBehaviour
{

    public GameObject gamepanel;
    void Start()
    {
        gamepanel = GameObject.FindGameObjectWithTag("GamePanel");
        
    }

    private void Update()
    {
        if (!GamePanel.instance.IsDeath)
        {
            GetComponent<Rigidbody2D>().simulated = true;
        }
        else
        {
            GetComponent<Rigidbody2D>().simulated = false;
        }
    }


    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.gameObject.name.Equals("Wall"))
        {
            Destroy(gameObject);
            ShortVoice.instance.PlayVoice("PaoDan");
            GameObject obj = Instantiate(Resources.Load<GameObject>("zha"));
            obj.transform.SetParent(gamepanel.transform);
            obj.transform.localPosition = transform.localPosition;
            
        }
    }


}
